package me.shurufa.activities;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;

import me.shurufa.R;
import me.shurufa.bean.Book;
import me.shurufa.fragments.MyCommentDetailFragment;
import me.shurufa.model.TopBook;
import me.shurufa.utils.Constants;

/**
 * 作者 : andy
 * 日期 : 16/3/8 17:50
 * 邮箱 : andyxialm@gmail.com
 * 描述 : 我的书架图书的详情界面
 */
public class MyCommentDetailActivity extends BaseActivity {

    private String bookTitle;
    private long bookId;
    private boolean mFromMe; // 是否是从我的书架 我的收藏 我的书评进来的，如果是的话 第二个下巴显示我的 点击“显示其他人的”
    private Book mBook;
    private int mWhereFrom;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        activity_layout_res = R.layout.activity_book_detail;
        super.onCreate(savedInstanceState);
        mWhereFrom = getIntent().getIntExtra(Constants.ARG_FROM_WHERE, Constants.TYPE_FROM_INTENT_DETAIL);
        mBook = (Book) getIntent().getSerializableExtra(Constants.ARG_BOOK);
        if (mBook != null) {
            bookId = mBook.id;
        }
        if (bookId == 0L)
            return;

        bookTitle = getIntent().getStringExtra(Constants.ARG_BOOK_TITLE);
        uiInit();
        initData();
    }

    private void initData() {
        MyCommentDetailFragment fragment = MyCommentDetailFragment.newInstance(mBook, mWhereFrom);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.fragment_container, fragment);
        transaction.commit();
    }

    private void uiInit() {
        if (!TextUtils.isEmpty(bookTitle)){
            titleTextView.setText(bookTitle);
        }
    }



}
